from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth import views as auth_views
from users.views import register
from pets.views import home
from pets.admin import admin_site  # 导入自定义管理站点

urlpatterns = [
    # 默认管理员后台
    path('admin/', admin.site.urls),
    
    # 自定义宠物领养系统管理后台
    path('pet-admin/', admin_site.urls),

    # 根路径（首页）→ 指向专门的首页视图
    path('', home, name='home'),

    # 宠物相关路由
    path('pets/', include('pets.urls')),

    # 用户相关路由
    path('register/', register, name='register'),
    path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
    path('logout/', auth_views.LogoutView.as_view(
        template_name='logout.html',
        next_page='home'
    ), name='logout'),

    # 密码重置功能
    path('password-reset/', 
         auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), 
         name='password_reset'),
    path('password-reset/done/', 
         auth_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'), 
         name='password_reset_done'),
    path('password-reset-confirm/<uidb64>/<token>/', 
         auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), 
         name='password_reset_confirm'),
    path('password-reset-complete/', 
         auth_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'), 
         name='password_reset_complete'),
]

# 开发环境下允许访问媒体文件
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)